package net.xxcxcxcx.xc_enhancedmob.packet.dirty;

/**
 * 一个用来维护数据有无修改的class。
 */
public class DataTracking<T> {
    private boolean dirty = false;
    private T value = null;

    public DataTracking() {

    }

    public DataTracking(T value) {
        this.setValue(value);
        this.setDirty(true);
    }

    public T getValue() {
        return value;
    }

    public void setValue(T value) {
        if (this.value != null && this.value.equals(value)) return;
        this.value = value;
        dirty = true;
    }

    public boolean isDirty() {
        return dirty;
    }

    public void setDirty(boolean dirty) {
        this.dirty = dirty;
    }
}
